import http from '@utils/request'
import { UserRuleForm, PhoneCodeForm, PhoneRuleForm, ILoginRequest } from '@interface/login'

//用户登录
export const loginByJson = (data: UserRuleForm): Promise<ILoginRequest> => {
  return http.post<ILoginRequest>('/u/loginByJson', data, {})
}

//获取图形验证码
export const captchaImage = (data: { key: string }): Promise<ArrayBuffer> => {
  return http.get<ArrayBuffer>('/captcha/image', data, { responseType: 'arraybuffer' })
}

//获取动态的验证码
export const loginCaptcha = (data: PhoneCodeForm): Promise<ILoginRequest> => {
  return http.post<ILoginRequest>('/captcha/sendRegisterOrLoginCaptcha', data, {})
}

//短信登录
export const msgLogin = (data: PhoneRuleForm): Promise<ILoginRequest> => {
  return http.post<ILoginRequest>('/u/loginByMobile', data, {})
}
